package com.hspedu.collection_;

import java.util.Comparator;
import java.util.TreeSet;
@SuppressWarnings({"all"})
public class TreeSet01 {
    public static void main(String[] args) {
        TreeSet treeSet = new TreeSet(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                if(((String) o1).length() - ((String)o2).length() == 0){
                    return -1;
                }else {
                    return 1;
                }
            }
        });
        treeSet.add("jack");
        treeSet.add("tom");
        treeSet.add("sp");
        treeSet.add("abc");
        treeSet.add("a");
        System.out.println(treeSet);
    }
}


































